package com.uenpay.im.invokeitems;

import com.qiyunxin.android.http.net.HttpInvokeItem;
import com.qyx.android.message.PushServiceShareData;
import com.uenpay.im.configuration.APIConfiguration;

import org.json.JSONObject;

/**
 * 
 * @author SL
 * @copyRight http://www.qiyunxin.com
 */
public class OfflineMsgInvokeItem extends HttpInvokeItem {

	public class OfflineMsgInvokeItemResult {
		public int status;
		public String msg;
	}

	public OfflineMsgInvokeItemResult getOutput() {
		return (OfflineMsgInvokeItemResult) GetResultObject();
	}

	/**
	 * 回复离线消息ack
	 * 
	 * @param msg_ids
	 *            消息ids
	 */
	public OfflineMsgInvokeItem(String msg_ids) {
		String url = APIConfiguration.getBaseUrl()
				+ "Chat/Chat/setUnreadMsgListACK?msgids=" + msg_ids
				+ "&_custid=" + PushServiceShareData.getInstance().getCustId()
				+ "&_token=" + PushServiceShareData.getInstance().getToken();
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) throws Exception {
		JSONObject json = new JSONObject(responseBody);
		OfflineMsgInvokeItemResult result = new OfflineMsgInvokeItemResult();

		result.status = json.optInt("status");
		result.msg = json.optString("msg");
		return result;
	}
}
